package com.medistat.dialog;

import java.util.ArrayList;
import java.util.List;

import com.medistat.model.enums.Days;

/**
 * Dialog object for representing Schedule on GUI.
 *
 */
public class Schedule extends AbstractDialogObject implements Comparable<Schedule>{
	
	private Integer year;
	private Integer week;
	private List<ScheduleSelection> scheduleSelections = new ArrayList<ScheduleSelection>();
	
	public Integer getYear() {
		return year;
	}
	public void setYear(Integer year) {
		this.year = year;
	}
	public Integer getWeek() {
		return week;
	}
	public void setWeek(Integer week) {
		this.week = week;
	}
	public List<ScheduleSelection> getScheduleSelections() {
		return scheduleSelections;
	}
	public void setScheduleSelections(List<ScheduleSelection> scheduleSelections) {
		this.scheduleSelections = scheduleSelections;
	}
	
	public void addToSheduleSelections(ScheduleSelection scheduleSelections) {
		getScheduleSelections().add(scheduleSelections);
	}
	
	public List<ScheduleCell> getCellsForDay(Days day) {
		List<ScheduleCell> cells = new ArrayList<ScheduleCell>();
		for(ScheduleSelection scheduleSelection : scheduleSelections) {
			int index = day.getValue();
			cells.add(scheduleSelection.getScheduleCells().get(index));
		}
		return cells;
	}
	
	@Override
	public int compareTo(Schedule schedule) {
		int week = this.getWeek().compareTo(schedule.getWeek());
		int year = this.getYear().compareTo(schedule.getYear());
		if(year==0) {
			return week;
		}
		return year;
	}	
}
